package com.lanqiao.javaparkinglot.controller;

import com.lanqiao.javaparkinglot.common.CommonResult;
import com.lanqiao.javaparkinglot.entity.Yg;
import com.lanqiao.javaparkinglot.service.YgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/ygtb")
public class YgController {
    @Autowired
    YgService ygService;
    //查询所有
    @GetMapping("/cha")
    public CommonResult findYg(Yg yg){
        List<Yg> ygList=ygService.findYg();
        return CommonResult.success("员工表查询成功",ygList);
    }
    //添加
    @PostMapping("/tianjia")
    public  CommonResult addyg (@RequestBody Yg yg){
        ygService.addyg(yg);
        return CommonResult.success("数据添加成功");
    }
    //修改
    @PutMapping("/xiugai")
    public CommonResult updateyg(@RequestBody Yg yg){
        ygService.updateyg(yg);
        return CommonResult.success("数据修改成功");
    }
    //删除
    @DeleteMapping("/{yg_id}")
    public CommonResult deleteyg(@PathVariable("yg_id")Long yg_id){
        ygService.deleteyg(yg_id);
        return CommonResult.success("删除成功");
    }
}
